{extend name="public/base"/}
{block name="style"}

<link rel="stylesheet" href="__PUBLIC__/plugs/tagsinput/bootstrap-tagsinput.css">
<script src="__PUBLIC__/plugs/tagsinput/bootstrap-tagsinput.js"></script>

<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/webuploader/webuploader.css">
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/plugs/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/plugs/ueditor/ueditor.all.min.js"></script>
<!-- datepicker statr -->
<link href="__PUBLIC__/plugs/datepicker/css/foundation-datepicker.min.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.js"></script>
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/board/board.min.css">
<!-- datepicker end -->
<style>
.uploadify-button-text{
    position: relative;
    display: inline-block;
    cursor: pointer;
    background: #fff;
    padding: 0px 5px;
    color: #333;
    text-align: center;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #ccc;
}
</style>
{/block}
{block name="body"}
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title}</h2>
		</div>
	</header>
	<div class="main-box-body clearfix">
		<form method="post" class="form form-horizontal">
			{if !isset($info)}
			{assign name="info" value="" /}
			{/if}
			{if !empty($fieldGroup)}
			<div class="tabs-wrapper">
				<ul class="nav nav-tabs">
					{volist name="fieldGroup" id="vGroup"}
					<li {if $i eq 1}class="active"{/if}><a href="#tab{$key}" data-toggle="tab">{$key}</a></li>
					{/volist}
				</ul>
				<div class="tab-content">
					{volist name="fieldGroup" id="vGroup"}
					<div class="tab-pane fade {if condition="$i eq 1"}in active{/if}" id="tab{$key}">
						{if condition="$i eq 1"}	
							<div class="form-group col-md-12">
								<label class="col-lg-1 control-label">电子书</label>
								<div class="col-lg-11 col-sm-10">
									<div class="picker-box">
										<div id="picker_ebook" class="picker_button">上传电子书</div>
										<input type="hidden" name="ebook" id="field_ebook" value="">
										<div id="fileList_ebook" class="upload-file-list-info" style="width:280px;"></div>
									</div>
										<script type="text/javascript">
											$(function(){
												$("#picker_ebook").SentUploader({
													server: "{:url('Upload/Uploadtxt')}",
													fileNumLimit: 1,
													uploadEvents: {
														uploadComplete: function (file) {
														}
													},
													listName: 'fileList_ebook',
													hiddenName: 'field_ebook',
													hiddenValType: 2,
													fileSingleSizeLimit: 50 * 1024 * 1024,
													closeX: true
												});
											});
										</script>
								</div>
								
							</div>
						{/if}
						{volist name="vGroup" id="field"}
						{if $field['is_show'] eq 1}
							<div class="form-group col-md-6">
								<label class="col-lg-2 control-label">{$field['title']|htmlspecialchars}</label>
								<div class="col-lg-10 col-sm-10">
									{:widget('common/Form/show',array($field,$info))}
								</div>
							</div>						
						{/if}
						
						{/volist}
						

						
					</div>
					{/volist}
				</div>
			</div>
			{/if}
			<div class="form-group">
				<div class="col-lg-offset-2 col-lg-10">
					<input type="hidden" name="id" value="{$info['id']|default=''}">            
					<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
					<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
				</div>
			</div>
		</form>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.custom.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/droppable.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/board/board.min.js"></script>

<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/uploadify/uploadify.css">

<script type="text/javascript" src="__PUBLIC__/plugs/uploadify/jquery.uploadify.min.js"></script>

<script language="javascript" type="text/javascript">
$(document).ready(function() {
	/*
	$("#upload_ebook").uploadify({
		swf : '__PUBLIC__/plugs/uploadify/uploadify.swf',
		uploader : "{:url('Upload/Uploadtxt')}",
        formData : {
            type : 'ebook',
            userid : '1'
        },
		buttonText : '选择电子书',
		buttonImage: "",
		width: "124",
		height: "33",
		fileObjName : 'ebook',
		fileTypeDesc : '支持格式：',
		fileTypeExts : '*.txt',
		fileSizeLimit : '100MB',
		queueSizeLimit : 1,
		multi : false,
		removeCompleted : false,
		onSelect : function(file) {
			$("#ebook").val("");
			var queuedFile = {};
			for (var n in this.queueData.files) {
				queuedFile = this.queueData.files[n];
				if (queuedFile.id !== file.id) {
					$('#' + queuedFile.id).remove();
					this.cancelUpload(queuedFile.id);
					delete this.queueData.files[n];
				}
			}
		},
		onUploadSuccess : function(file, data) {
			$("#ebook").val(data);
			$('#' + file.id).find('.cancel').hide();
			$('#' + file.id).find('.uploadify-progress').hide();
			if (data == "") {
				$('#' + file.id).find('.data').html(' - <font color="red">上传失败！</font>');
				return false;
			}
			$('#' + file.id).find('.data').html(' - <font color="green">上传成功！</font>');
		}
	});
	*/
	
});

</script>
<script type="text/javascript">
var url="{:url('admin/category/getcategory')}"

	$(function(){
		$('#channel').on('change',function () {
            var value = $(this).val();
			$("#category_id").empty();
			$.ajax({
				  url: url,
				  type: 'get',
				  data: {model:1,type:value},				  
				  dataType: 'json',
				  success:function(json){
					  
					  if (json.code==1)
					  {
						  var html="<option value=''>未选择</option>";
						  $.each(json.data, function(i, v) {
							html += "<option value='"+i+"'>"+v+"</option>";
						  })
						  //console.log(html);
						  $("#category_id").append(html); 
					  }
				  }
			});
		});

		var url2="{:url('admin/thirdnovel/getdata')}"
		$('#siteid').on('change',function () {
			var value = $(this).val();
			$("#sourceid").empty();
			$.ajax({
					url: url2,
					type: 'get',
					data: {model:1,siteid:value},				  
					dataType: 'json',
					success:function(json){
						
						if (json.code==1)
						{
							var html="<option value=''>未选择</option>";
							$.each(json.data, function(i, v) {
							html += "<option value='"+i+"'>"+v+"</option>";
							})
							console.log(html);
							$("#sourceid").append(html); 
						}
					}
			});
		});
		var sourceid = '{$info["sourceid"] || default=0}'
		if(sourceid){
			var value = '{$info["siteid"] || default=0}'
			// alert(1)
			$.ajax({
					url: url2,
					type: 'get',
					data: {model:1,siteid:value},				  
					dataType: 'json',
					success:function(json){
						if (json.code==1)
						{
							var html="<option value=''>未选择</option>";
							$.each(json.data, function(i, v) {
								if(i == sourceid){
									html += "<option value='"+i+"' selected=true>"+v+"</option>";
								}else{
									html += "<option value='"+i+"'>"+v+"</option>";
								}
							})
							console.log(html);
							$("#sourceid").append(html); 
						}
					}
			});
		}
	})
</script>

{/block}